<?php

namespace app\admin\controller\mysql;

use app\admin\service\demo\DemoService;
use app\admin\service\mysql\MysqlToolsService;
use app\common\controller\CommonBaseController;
use app\common\utils\ApiReturn;
use app\common\utils\MyLog;
use app\common\validate\demo\DemoValidate;
use app\Request;

/**
 * MySQL工具类
 */
class MysqlTools extends CommonBaseController
{
    /**
     * 将数据表的数据值转换为json格式
     * @param Request $request
     * @return void
     */
    public function tableValueToJson(Request $request)
    {
        try {
            $this->checkParams([
                'table_name' => 'require', //数据表名称
            ]);
            $result = MysqlToolsService::tableValueToJson($this->params['table_name'], true);
            ApiReturn::retData($result);
        } catch (\Exception|\Error $e) {
            ApiReturn::retError($e);
        }
    }
}